<?php
declare (strict_types = 1);
namespace app\common\model\advert;

use app\common\model\BaseModel;
use think\facade\Config;

/**
 * 定义广告图位置
 */
class AdvertPlace extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'advert_place';

    /**
     * 定义表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 全局查询范围
     * @var [type]
     */
    protected $globalScope = ['openApp'];

    /**
     * 定义查询分类类型范围条件
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-03-10
     * @param    [type]                         $query [description]
     * @return   [type]                                [description]
     */
    public function scopeOpenApp($query)
    {
        $apps   = Config::get('eduline.appinfo.open_app', []);
        $apps[] = 'public';
        $query->whereIn('app', $apps);
    }
}
